<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCommodityColorsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('commodity_colors', function (Blueprint $table) {
            $table->increments('commodity_color_id')->comment("商品颜色ID,自增");
            $table->integer('commodity_id')->unsigned()->comment("所属商品ID");
            $table->string('commodity_color_name',50)->comment("商品颜色名字");
            $table->engine = 'InnoDB';
            $table->index('commodity_color_id');
            $table->foreign('commodity_id')->references('commodity_id')->on('commoditys');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('commodity_colors');
    }
}
